/*
 * controler.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef ACTIVECABLEMODEL_H_
#define ACTIVECABLEMODEL_H_

#include "numerics/minimizer.h"
#include "geometry/geomobject.h"
#include "../../../core/SubstrateModel.h"
#include "../../../core/CellModel.h"
#include "../../../base/utility/FieldInterpolation2D.h"

#include <string>

using namespace std;

class ActiveCableModel : public CellModel {
protected:
	Minimizer * min;
	GeomObject * g;
	vector<int> fiber_list;
	string FILENAME, OUTPUT_FOLDER;
	double SPRING_CONSTANT;
	int snapshot_interval;

	void initFibres(vector<double> tensions);
public:
	static const int FIELD_FIBRETYPE = 1;
	static const int FIELD_TENSION = 2;
	static const int FIELD_FIBRENUMBER = 3;

	static const int TYPE_NETWORK = 1, TYPE_DORSAL = 2, TYPE_VENTRAL = 3, TYPE_TVA = 4, TYPE_EDGEBUNDLE = 5;

	ActiveCableModel(string filename, string output_folder, double spring_constant, vector<double> PARAMETERS); //tensions[0] = network tension
	virtual ~ActiveCableModel(){
		delete min;
		delete g;
	};
	void setInitialConfiguration(vector<Vertex> pos);
	void setTensions(vector<double> tensions);
	void minimize(int max_iterations);
	vector<Vertex*>* getVertices(){return g->getVertices();};
	vector<Vertex> copyVertices();
	vector<Vertex> getTractions();

	GeomObject* getGeomObject();

	vector<double> get_fiber_lengths();
	vector<int> get_fiber_types();

	vector<int> getFiberList(){return fiber_list;};

	static vector<int> getFiberList(string filename);
	static void createShiftedVTK(string orig_vtk_filename, string dest_vtk_filename, FieldInterpolation2D * exp_displacements);
	void cut(Edge e);
	void set_snapshot_interval(int i){ snapshot_interval = i; };

	//define inherited methods
	virtual void run();
	vector<double> get_parameters() {return parameters;};
	void set_parameters(vector<double> p) {setTensions(p); parameters=p;};
	void set_initial_configuration(vector<double> init_config);
	vector<double> get_final_configuration();
	virtual ActiveCableModel * clone() const;
	virtual vector<ForceTransmission*> getForceTransmissionShapes();
};

#endif /* ACTIVECABLEMODEL_H_ */
